package test5;

import test5.CircleException;

public class Circle {
    private double radius;

    public void setRadius(double r) throws CircleException {
        if( r<0) {
            throw new CircleException(r);
        } else {
            radius = r;
        }
    }

    public void show() {
        System.out.println("圆面积="+3.14*radius*radius);
    }
}

class CircleException extends Exception {
    double radius;
    CircleException(double r) {
        radius = r;
    }
    public String toString() {
        return "半径r=" + radius + "不是一个正数";
    }
}